close all
clear all
clc 
% This throughput_smaples.mat file contains the following variables,
%
% throughput_prks95  throughput_prks90  throughput_prks80  throughput_prks70 
% throughput_rid95  throughput_rid90  throughput_rid80  throughput_rid70 
% throughput_cmac95  throughput_cmac90  throughput_cmac80  throughput_cmac70 
% I-ORDER is currently not included! 
% throughput_csma 
% throughput_rtscts 
% throughput_scream 

load throughput_samples.mat

ALPHA=0.05;

MEAN = zeros(4,6);
Error_MEAN = zeros(4,6);
MEAN(1,1) = mean(throughput_prks70);
MEAN(1,2) = mean(throughput_csma);
MEAN(1,3) = mean(throughput_rtscts);
MEAN(1,4) = mean(throughput_rid70);
%MEAN(1,5) = mean(throughput_iorder70);
Error_MEAN(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_prks70) / sqrt(size(throughput_prks70, 1));
Error_MEAN(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_csma) / sqrt(size(throughput_csma, 1));
Error_MEAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rtscts) / sqrt(size(throughput_rtscts, 1));
Error_MEAN(1,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rid70) / sqrt(size(throughput_rid70, 1));
MEAN(1,5) = mean(throughput_cmac70);
Error_MEAN(1,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_cmac70) / sqrt(size(throughput_cmac70, 1));
MEAN(1,6) = mean(throughput_scream);
Error_MEAN(1,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_scream) / sqrt(size(throughput_scream, 1));
%Error_MEAN(1,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_iorder70) / sqrt(size(throughput_iorder70, 1));
MEAN(2,1) = mean(throughput_prks80);
MEAN(2,2) = mean(throughput_csma);
MEAN(2,3) = mean(throughput_rtscts);
MEAN(2,4) = mean(throughput_rid80);
%MEAN(2,5) = mean(throughput_iorder80);

Error_MEAN(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_prks80) / sqrt(size(throughput_prks80, 1));
Error_MEAN(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_csma) / sqrt(size(throughput_csma, 1));
Error_MEAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rtscts) / sqrt(size(throughput_rtscts, 1));
Error_MEAN(2,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rid80) / sqrt(size(throughput_rid80, 1));
MEAN(2,5) = mean(throughput_cmac80);
Error_MEAN(2,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_cmac80) / sqrt(size(throughput_cmac80, 1));
MEAN(2,6) = mean(throughput_scream);
Error_MEAN(2,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_scream) / sqrt(size(throughput_scream, 1));
%Error_MEAN(2,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_iorder80) / sqrt(size(throughput_iorder80, 1));
MEAN(3,1) = mean(throughput_prks90);
MEAN(3,2) = mean(throughput_csma);
MEAN(3,3) = mean(throughput_rtscts);
MEAN(3,4) = mean(throughput_rid90);
%MEAN(3,5) = mean(throughput_iorder90);

Error_MEAN(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_prks90) / sqrt(size(throughput_prks90, 1));
Error_MEAN(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_csma) / sqrt(size(throughput_csma, 1));
Error_MEAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rtscts) / sqrt(size(throughput_rtscts, 1));
Error_MEAN(3,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rid90) / sqrt(size(throughput_rid90, 1));
MEAN(3,5) = mean(throughput_cmac90);
Error_MEAN(3,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_cmac90) / sqrt(size(throughput_cmac90, 1));
MEAN(3,6) = mean(throughput_scream);
Error_MEAN(3,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_scream) / sqrt(size(throughput_scream, 1));
%Error_MEAN(3,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_iorder90) / sqrt(size(throughput_iorder90, 1));
MEAN(4,1) = mean(throughput_prks95);
MEAN(4,2) = mean(throughput_csma);
MEAN(4,3) = mean(throughput_rtscts);
MEAN(4,4) = mean(throughput_rid95);
%MEAN(4,5) = mean(throughput_iorder95);

Error_MEAN(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_prks95) / sqrt(size(throughput_prks95, 1));
Error_MEAN(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_csma) / sqrt(size(throughput_csma, 1));
Error_MEAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rtscts) / sqrt(size(throughput_rtscts, 1));
Error_MEAN(4,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_rid95) / sqrt(size(throughput_rid95, 1));
MEAN(4,5) = mean(throughput_cmac95);
Error_MEAN(4,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_cmac95) / sqrt(size(throughput_cmac95, 1));
MEAN(4,6) = mean(throughput_scream);
Error_MEAN(4,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_scream) / sqrt(size(throughput_scream, 1));
%Error_MEAN(4,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(throughput_iorder95) / sqrt(size(throughput_iorder95, 1));

figure;
handle = barweb(MEAN, Error_MEAN,1, ['70';'80';'90';'95'], [], ['PDR requirement(%)'], ['Mean throughput'], jet);
handle.legend =legend ('PRKS','CSMA','RTS-CTS', 'RIDB','CMAC','SCREAM','orientation','horizontal');
set(gca,'fontsize',20);
box on
maximize ();
saveas(gcf, 'temp.fig');
%[im_hatch, colorlist]=applyhatch_pluscolor(gcf, '/-\xkc',1,[1 1 1 1 0 1],[],[],5,10);


